package com.person.monitor.location;

import android.app.Activity;
import android.content.Context;

import com.person.monitor.LogcatHelper;
import com.person.monitor.MyLog;

public abstract class BaseLocation {

    public interface OnLocationCompleteListener{
        void onSuccess(LocRet locRet);
        void onFail(String msg);
    }

    private LocRet locRet = new LocRet(0f,0f,"");

    Context activity;

    OnLocationCompleteListener onLocationCompleteListener;

    public BaseLocation(Context activity){
        this.activity = activity;
    }

    public void setOnLocationCompleteListener(OnLocationCompleteListener l){
        onLocationCompleteListener = l;
    }

    abstract public void startLocation();

    abstract public void stopLocation();

    protected void locationSuccess(double lat,double lng, String adr){
        locRet = new LocRet(lat,lng,adr);

        if(onLocationCompleteListener != null){
            onLocationCompleteListener.onSuccess(new LocRet(lat,lng,adr));
        }

        MyLog.D("locationSuccess="+locRet);
    }

    protected void locationFail(String msg){
        if(onLocationCompleteListener != null){
            onLocationCompleteListener.onFail(msg);
        }
    }

    public LocRet getLocRet() {
        return locRet;
    }
}
